#include <stdio.h>
#include <SDL2/SDL.h>

#include "hal_thermal.h"
#include "msg_thermal.h"

/*
#GUI下发强制执行一次快门矫正
echo shutter,once  > /tmp/daemon_in

#GUI下发强制执行一次背景矫正
echo shutter,background  > /tmp/daemon_in

#GUI下发手动快门模式
echo shutter,manul  > /tmp/daemon_in

#GUI下发自动快门模式
echo shutter,auto > /tmp/daemon_in

#GUI下发均匀面矫正指令
/mnt/default/thermal_cali0 -c /tmp/config.ini -o /mnt/mtd 

#GUI下发采集低温图像
echo calibration,low > /tmp/daemon_in

#GUI下发采集高温图像
echo calibration,high > /tmp/daemon_in

#GUI下发执行矫正指令
/mnt/default/thermal_cali1 -c /tmp/config.ini -o /mnt/mtd --bt1data=/tmp/RAW_14BIT_LOW.raw --bt2data=/tmp/RAW_14BIT_HIGH.raw &
*/
int hal_thermal_bg_cal(void)
{
    return system("echo shutter,background > /tmp/daemon_in");
}

int hal_thermal_shutter_cal(void)
{
    return system("echo shutter,once > /tmp/daemon_in");
}

int hal_thermal_shutter_onoff(int onoff)
{
    return 0;
}
/*
 	if (0 == idx)
	    ptbl = Black_Hot_Warm;  // 黑热
	else if (1 == idx)
	    ptbl = White_Hot_Warm;  // 白热
	else if (2 == idx)
	    ptbl = Red_Hot_Warm;    // 红热
	else if (3 == idx)
	    ptbl = Green_Fire_Blue; // 蓝绿火焰
	else if (4 == idx)
	    ptbl = Ironbow;         // 热铁
	else if (5 == idx)
	    ptbl = spectrum_002;    // 频谱
	else if (6 == idx)
	    ptbl = Jet;             // 喷气 (常见于伪彩色)
	else if (7 == idx)
	    ptbl = siemens;         // 西门子
	else if (8 == idx)
	    ptbl = Viridis;         // 绿色 (Viridis 维瑞迪斯配色方案)
	else if (9 == idx)
	    ptbl = RedHot;          // 红色
	else if (10 == idx)
	    ptbl = neon_green;      // 绿色 (霓虹绿)
	else if (11 == idx)
	    ptbl = cmy_yellow;      // 黄色 (CMY图像的黄色)
	else if (12 == idx)
	    ptbl = fire_001;        // 火焰
	else if (13 == idx)
	    ptbl = GreenFire;       // 冷火
	else if (14 == idx)
	    ptbl = Lava_Warm;       // 熔岩 (温暖)
	else if (15 == idx)
	    ptbl = Edges_red;       // 描边 (红色)	
 */
int hal_thermal_color_mode(int value)
{
    return hal_thermal_set_palette(value);
}

int hal_thermal_auto_shutter_onoff(int onoff)
{
    if (onoff) {
        return system("echo shutter,auto > /tmp/daemon_in");
    } else {
        return system("echo shutter,manul > /tmp/daemon_in");
    }
}